package gui;


import java.net.URL;
import java.util.ResourceBundle;

import objects.User;

import managers.UserManager;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;

public class LoginController implements Initializable {

    @FXML private Button buttLogin; // Value injected by FXMLLoader
    @FXML private TextField username;
    @FXML private PasswordField password;


    @Override // This method is called by the FXMLLoader when initialization is complete
    public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
        assert buttLogin != null : "fx:id=\"buttLogin\" was not injected: check your FXML file 'simple.fxml'.";
        assert username != null : "fx:id=\"username\" was not injected: check your FXML file 'simple.fxml'.";
        assert password != null : "fx:id=\"password\" was not injected: check your FXML file 'simple.fxml'.";
        
       

        // initialize your logic here: all @FXML variables will have been injected
        buttLogin.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                System.out.println("Logging in or creating user!");
                UserManager.setCurrentUser(new User(username.getText(), password.getText()));
            }
        });

    }

}